package zhang.test.netfits_youmeng;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.umeng.analytics.MobclickAgent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by Administrator on 2016/12/12.
 */

public class payModeActivity extends AppCompatActivity {
    @BindView(R.id.lv)
    ListView lv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay);
        ButterKnife.bind(this);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);//这句话必须要写

        initUI();
    }

    private void initUI() {
        final List ls = new ArrayList();
        ls.add("pay1");
        ls.add("pay2");
        ls.add("pay3");

        lv.setAdapter(new ArrayAdapter<String>(this, R.layout.item, R.id.tv, ls));
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(payModeActivity.this, "" + ls.get(i), Toast.LENGTH_SHORT).show();

                HashMap<String,String> map = new HashMap<String,String>();
                map.put("mode", ls.get(i) + "");
                MobclickAgent.onEvent(payModeActivity.this, "payMode", map);
                startActivity(new Intent(payModeActivity.this, ResultZActivity.class));
            }
        });
    }

    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.bind(this).unbind();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            MobclickAgent.onEvent(payModeActivity.this, "back");
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
